package com.smec.moblie.activity;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.widget.Toast;

import com.smec.moblie.R;
import com.smec.moblie.view.photoview.PhotoView;

import java.io.File;

/**
 * Created by sunyubo on 2017/3/21.
 */

public class PhotoShowBigActivity extends Activity {
    private PhotoView photoView;

    private String imagePath;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_photo_show_big);
        initView();
        getData();
    }

    private void initView() {
        imagePath = getIntent().getStringExtra("ImagePath");
        photoView = (PhotoView)findViewById(R.id.photo_view);
    }

    private void getData() {
        File file = new File(imagePath);
        if (file.exists()) {
            BitmapFactory.Options options = new BitmapFactory.Options();
            Bitmap showBitmap = BitmapFactory.decodeFile(imagePath, options);
            photoView.setImageBitmap(showBitmap);
        } else {
            Toast.makeText(PhotoShowBigActivity.this, "未获取到本地照片", Toast.LENGTH_SHORT).show();
        }
    }

}
